package com.lxy.demo.login;

import org.aspectj.lang.ProceedingJoinPoint;

import java.util.Arrays;

public class LoginTest {
    private String name = "admin";
    private String pwd = "123";

    public void login(ProceedingJoinPoint joinPoint) {
        if (name.equals("admin") && pwd.equals("13")) {
            System.out.println("通知。。。登录成功");
            System.out.println("通知。。。手机安全");
            try {
                //joinPoint.proceed();让目标方法执行 拥有目标方法的返回值
                Object returnValue = joinPoint.proceed();
                System.out.println("返回通知...目标方法的返回值" + returnValue+
                        "目标方法的参数"+ Arrays.toString(joinPoint.getArgs()));
            } catch (Throwable e) {
                e.printStackTrace();
                System.out.println("异常通知。。目标的方法名："
                        + joinPoint.getSignature().getName()
                        + "异常类型" + e);
            }
        }else {
            System.out.println("登录失败！");
        }
    }
}
